
require "skynet.manager"
local skynet = require "skynet"
local NodeMessage = require "NodeMessage"
local MessageDispatch = require "MessageDispatch"
local MessageHandler = require "manager.MessageHandler"
local ClusterManager = require("ClusterManager")
local ServerInfo = require("ServerInfo")






global = {}
local function init()

	local message_dispatch = MessageDispatch.new()	
	local node_message = NodeMessage.new()
	local message_handler = MessageHandler.new(message_dispatch, node_message)
	local cluster_manager = ClusterManager.new(message_dispatch)
	local server_info = ServerInfo.new() --节点相关信息


	global.server_info = server_info	
	global.node_message = node_message
	global.cluster_manager = cluster_manager


	skynet.dispatch("lua", message_dispatch:dispatch())	
	--开启集群节点
	cluster_manager:open(server_info)		
end

---------------------------------------------------------
-- skynet
---------------------------------------------------------

skynet.start(function()		
	skynet.register('.manager')
	init()
end)
